#include <iostream>
using namespace std;

struct ListNode {
	int val;
	ListNode* next;
	ListNode(int x) : val(x), next(nullptr) {}
};

ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {
	if (!l1) return l2;
	if (!l2) return l1;
	
	ListNode* head = nullptr;
	if (l1->val < l2->val) {
		head = l1;
		l1 = l1->next;
	} else {
		head = l2;
		l2 = l2->next;
	}
	
	ListNode* current = head;
	while (l1 && l2) {
		if (l1->val < l2->val) {
			if(l1->val==current->val)
			{
				l1 = l1->next;
				continue;
			}
			current->next = l1;
			l1 = l1->next;
		} else {
			if(l2->val==current->val)
			{
				l1 = l1->next;
				continue;
			}
			current->next = l2;
			l2 = l2->next;
		}
		current = current->next;
	}
	
	if (l1) current->next = l1;
	if (l2) current->next = l2;
	
	return head;
}

void printList(ListNode* head) {
	while (head) {
		cout << head->val;
		if (head->next) cout << " ";
		head = head->next;
	}
	cout << endl;
}

ListNode* createList(const int arr[], int size) {
	if (size == 0) return nullptr;
	ListNode* head = new ListNode(arr[0]);
	ListNode* current = head;
	for (int i = 1; i < size; ++i) {
		current->next = new ListNode(arr[i]);
		current = current->next;
	}
	return head;
}

int main() {
	// 示例输入
	int i=0;
	char arr1[] = {4, 7, 10, 34};
	while(cin>>arr1[i++])
	{
		if(arr1[i-1]=='\n')break;	
	}
		i=0;
	char arr2[] = {1, 4, 6, 9, 34, 52};
	while(cin>>arr2[i++])
	{
		if(arr2[i-1]=='\n')break;	
	}
	int size1 = sizeof(arr1) / sizeof(arr1[0]);
	int size2 = sizeof(arr2) / sizeof(arr2[0]);
	
	ListNode* l1 = createList(arr1, size1);
	ListNode* l2 = createList(arr2, size2);
	
	ListNode* mergedList = mergeTwoLists(l1, l2);
	
	printList(mergedList);
	
	return 0;
}

